import { createStore } from "redux";
const reducer = (state = 1, action) => {
    switch (action.type) {
        case 'plus':
            return state + 1
        case 'mius':
            return state - 1
        default:
            return state
    }
}
const store = createStore(reducer);
const unSubscribe = store.subscribe(() =>
    console.log(store.getState())
)
store.dispatch({
    type: 'plus'
})
// console.log(store.getState());

store.replaceReducer((state = 1, action) => {
    switch (action.type) {
        case 'mius':
            return state - 1
        case 'plus':
            return state + 1
        default:
            return state
    }
})
store.dispatch({
    type: 'plus'
})
// console.log(store.getState());
unSubscribe()
store.dispatch({
    type: 'mius'
})
// console.log(store.getState());
export default store